package com.heima.Exception.DIYExecption;

import java.util.Scanner;

/**
 * @Author: Ethan Yankang
 * @Program: 面试必会代码
 * @Date: 2024-08-28 22:08
 **/
public class DivisionCalculator {
    public static float Division(float numerator,float denominator) throws DIYExecption {
        if (denominator==0){
            throw new DIYExecption("分子不能为0，输入异常");
        }
        return denominator/numerator;
    }

    public static void main(String[] args) {
        System.out.println("请输入分子分母");
        Scanner input = new Scanner(System.in);
        int numerator = input.nextInt();
        int denominator = input.nextInt();
        /*
         * @description用标准的try-catch语句块来执行
         * @params
         * @return
         */

        try {
            System.out.println(DivisionCalculator.Division(numerator,denominator));
        }catch (DIYExecption execption){
            System.out.println("发生异常"+execption.getMessage());
        }finally {
            System.out.println("程序执行完毕");
        }

    }
}
